package com.capgemini.data;

import java.sql.Date;
import java.util.ArrayList;
import java.util.List;

public class Trainer extends Person {

	private List<Long> athletes;

	private boolean formerAthlete;
	private String trainerHierarchy;

	public Trainer() {

	}

	public Trainer(String name, String surName, Date birthDate,
			String nationality, boolean former, String hierarchy) {
		super(name, surName, birthDate, nationality);
		this.formerAthlete = former;
		this.trainerHierarchy = hierarchy;
		this.athletes = new ArrayList<Long>();
	}

	public boolean isFormerAthlete() {
		return formerAthlete;
	}

	public void setFormerAthlete(boolean formerAthlete) {
		this.formerAthlete = formerAthlete;
	}

	public String getTrainerHierarchy() {
		return trainerHierarchy;
	}

	public void setTrainerHierarchy(String trainerHierarchy) {
		this.trainerHierarchy = trainerHierarchy;
	}

	public List<Long> getAthletes() {
		return athletes;
	}

	public void addAthletes(Long athlete) {
		if (this.athletes == null) {
			this.athletes = new ArrayList<Long>();
		}
		this.athletes.add(athlete);
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = super.hashCode();
		result = prime * result
				+ ((athletes == null) ? 0 : athletes.hashCode());
		result = prime * result + (formerAthlete ? 1231 : 1237);
		result = prime
				* result
				+ ((trainerHierarchy == null) ? 0 : trainerHierarchy.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (!super.equals(obj))
			return false;
		if (getClass() != obj.getClass())
			return false;
		Trainer other = (Trainer) obj;
		if (athletes == null) {
			if (other.athletes != null)
				return false;
		} else if (!athletes.equals(other.athletes))
			return false;
		if (formerAthlete != other.formerAthlete)
			return false;
		if (trainerHierarchy == null) {
			if (other.trainerHierarchy != null)
				return false;
		} else if (!trainerHierarchy.equals(other.trainerHierarchy))
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "Trainer [athletes=" + athletes + ", formerAthlete="
				+ formerAthlete + ", trainerHierarchy=" + trainerHierarchy
				+ "]";
	}

}
